package com.xhs.service.impl;

import lombok.extern.slf4j.Slf4j;

/**
 * @desc: 继承Thread类创建线程
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/5 21:29
 * @version: JDK 1.8
 */
@Slf4j
public class Thread1ServiceImpl extends Thread {
    @Override
    public void run() {
        log.info(">>>>>>>>>>>>>>继承Thread类创建线程:{},我是子线程<<<<<<<<<<<<<<<<<<<<", Thread.currentThread().getName());
    }

    public static void main(String[] args) {
        log.info(">>>>>>>>>>>>>>继承Thread类创建线程:{}，我是主线程<<<<<<<<<<<<<<<<<<<<", Thread.currentThread().getName());
        Thread1ServiceImpl thread1 = new Thread1ServiceImpl();
        // 启动线程是start方法而不是run方法
        thread1.start();
        log.info(">>>>>>>>>>>>>>继承Thread类创建线程:{}，我是主线程<<<<<<<<<<<<<<<<<<<<", Thread.currentThread().getName());
    }
}
